package com.sky.controller.user;

import com.sky.dto.UserLoginDTO;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.openxml4j.opc.internal.ContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bairimengchang
 * @version 1.0
 * @project sky-take-out
 * @description C端用户控制器
 * @date 2024/08/15 17:16:09
 */
@RestController
@RequestMapping("/user/user")
@Slf4j
@Api(tags = "C端用户接口")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * C端用户登录
     * @param userLoginDTO 用户数据传输数据模型
     * @return 用户视图结果对象
     */
    @ApiOperation("C端用户登录")
    @PostMapping("/login")
    public Result<UserLoginVO> login(@RequestBody UserLoginDTO userLoginDTO) {
        log.info("C端用户登录,userLoginDTO:{}", userLoginDTO);
        UserLoginVO userLoginVO = userService.login(userLoginDTO);
        return Result.success(userLoginVO);
    }

    /**
     * C端用户退出
     * @param contentType 未知
     * @return 退出成功
     */
    @ApiOperation("C端用户退出")
    @PostMapping("/logout")
    public Result<String> logout(@RequestBody(required = false) ContentType contentType){
        // TODO 退出功能暂时没用
        log.info("C端用户退出");
        return Result.success();
    }

}
